package com.xdjd.task.service.daoservice;

import com.xdjd.task.mapper.activity.ActivityClockDetailPoDao;
import com.xdjd.task.model.activity.ActivityClockDetailPo;
import net.oschina.durcframework.easymybatis.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ActivityClockDetailPoService {

    @Autowired
    private ActivityClockDetailPoDao activityClockDetailPoDao;

    public void settleClockDetail(){
        activityClockDetailPoDao.settleSuccessClockDetail();
        activityClockDetailPoDao.settleFailureClockDetail();
    }

    public ActivityClockDetailPo findByClockNoAndDate(String clockNo, String date) {
        return activityClockDetailPoDao.getByExpression(new Query().eq("clock_no", clockNo).eq("clock_date", date));
    }

    public void saveClockDetail(ActivityClockDetailPo po) {
        po.setCreateTime(new Date());
        po.setModifyTime(new Date());
        activityClockDetailPoDao.save(po);
    }

    public void updateClockDetail(ActivityClockDetailPo po) {
        po.setModifyTime(new Date());
        activityClockDetailPoDao.update(po);
    }
}
